package com.zhouyu.exampleboot.util;

import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Description:
 *
 * @author zhouyu
 * @create 2020/10/15
 * @since 1.0.0
 */
public class RestUtil {
    public static void getParam(){
        RestTemplate client = new RestTemplate();
        Map<String, String> map = new LinkedHashMap<>();
        map.put("name", "李四");
        client.getForEntity("http://HELLO-SERVICE/sayhello?name={name}", String.class, map);
    }
    public static void post(String url){
        StringBuffer append = new StringBuffer("https://cas.zemcho.com/ssoapi/v2/checkToken")
                .append("?token={token}")
                .append("&appid={appid}")
                .append("&appsecret={appsecret}")
                .append("&userip={userip}");
        String urlPatern = append.toString();
        RestTemplate client = new RestTemplate();
        Map<String, String> map = new LinkedHashMap<>();
        map.put("token","szlr-z-b611a22b64459f05f74ad85ad6256f87");
        map.put("appid","szlr");
        map.put("appsecret","123456789");
        map.put("userip","183.39.24.75");
        ResponseEntity<CheckTokenBackRsp> responseEntity = client.postForEntity(urlPatern,null, CheckTokenBackRsp.class,map);
        CheckTokenBackRsp body = responseEntity.getBody();
        System.out.println(body.toString());
    }
}
